#pragma once
#include "hzpch.h"
#include "Core/Core.h"

/*
 * 着色器基类 主要功能创建相关api着色器
 * ShaderLibrary 缓存
 * */
namespace Hazel {
    class Shader {
    public:
//        Shader(const std::string& vertexSrc, const std::string& fragmentSrc);
        ~Shader()= default;
        virtual void Bind() const = 0;
        virtual void Unbind() const = 0;
        virtual const std::string& GetName() const = 0;
        virtual void SetMat4(const std::string& name, const glm::mat4& value) = 0;
        virtual void SetFloat3(const std::string& name, const glm::vec3& value) = 0;
        virtual void SetFloat4(const std::string& name, const glm::vec4& value) = 0;
//        void UploadUniformMat4(const std::string& name, const glm::mat4& matrix);
        virtual void SetInt(const std::string& name, const int value) = 0;

        static Ref<Shader> Create(const std::string& filePath);
        static Ref<Shader> Create(const std::string& name, const std::string& vertexSrc, const std::string& fragmentSrc);
//    private:
//        uint32_t m_RendererID;
    };

    class ShaderLibrary {
    public:
        void Add(const std::string& name, const Ref<Shader>& shader);
        void Add(const Ref<Shader>& shader);
        Ref<Shader> Load(const std::string& filePath);

        Ref<Shader> Load(const std::string& name, const std::string& filePath);
        Ref<Shader> Get(const std::string& name) const;
        bool Exists(const std::string& name) const;
    private:
        std::unordered_map<std::string, Ref<Shader>> m_Shaders;
    };
}
